#!/bin/sh
#-----------------------------------------------------------------------
#
# VISIT-STRIP-PARALLEL - Strips the parallel Linux distributions of the
#                        parallel portions of visit.
#
# Author: Eric Brugger
# Date:   June 9, 2010
#
# Usage:
#    visit-strip-parallel -v <version>
#
#-----------------------------------------------------------------------

version=undefined

#
# The loop is executed once for each symbol on the execute line.  This means
# that $1 may be blank for later executions of the loop if any "shift 2"
# commands are executed.  The variable abc is not used in the loop.  
#
for abc
do
   case $1 in
      -v)
         version=$2
         shift 2
         ;;
   esac
done

#
# Check that the distribution version number was provided.
#
if [ $version = undefined ]
then
   echo "Usage: -v <version>"
   exit
fi

version2=`echo $version | tr "." "_"`

#
# Strip the distributions.
#
dists="linux-ubuntu8 linux-x86_64-ubuntu8 linux-x86_64-rhel4 linux-x86_64"
for dist in $dists
do
   if [ -e "visit$version2.$dist.tar.gz" ]
   then
      echo "Creating stripped version visit$version2.$dist.web.tar.gz"
      case $dist in
         linux-ubuntu8)
            dist2=linux-intel
            ;;
         linux-x86_64-ubuntu8)
            dist2=linux-x86_64
            ;;
         linux-x86_64-rhel4)
            dist2=linux-x86_64
            ;;
         linux-x86_64)
            dist2=linux-x86_64
            ;;
       esac

       rm -rf visit$version2.$dist2
       tar zxf visit$version2.$dist.tar.gz
       find visit$version2.$dist2 -name "*_par.so" -exec rm {} \;
       find visit$version2.$dist2 -name "engine_par" -exec rm {} \;
       find visit$version2.$dist2 -name "visitconvert_par" -exec rm {} \;
       rm -f visit$version2.$dist.web.tar.gz
       tar cbf 20 - visit$version2.$dist2 | gzip > visit$version2.$dist.web.tar.gz
       rm -rf visit$version2.$dist2
   fi
   
   shift
done
